package com.gxa.jjty.admin.controller;

import com.gxa.jjty.admin.service.OrdersetService;
import com.gxa.jjty.core.common.JsonResult;
import com.gxa.jjty.core.pojo.Orderset;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.v3.oas.annotations.parameters.RequestBody;
import lombok.extern.log4j.Log4j2;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 * @author wanjun
 * @version 1.0
 * @date 2021/12/1 20:22
 */
@Log4j2
@Api(tags = "后台订单设置接口")
@RestController
@RequestMapping("/OrderSet")
@Validated
public class OrdersetController {

    @Autowired
    OrdersetService ordersetService;

    @PostMapping("/select")
    @ApiOperation("后台查询订单设置")
    public Map<String,Object> selectAll(){
        List<Orderset> ordersets = ordersetService.selectAll();
        return new JsonResult("1","成功",ordersets).getDataMap();
    }

    @PostMapping("/update")
    @ApiOperation("后台修改订单设置")
    public Map<String,Object> update(@Validated @RequestBody Orderset orderset) throws IllegalAccessException {
        orderset.setOrdersetId(1L);
        ordersetService.updateById(orderset);
        return new JsonResult("1","成功","").getDataMap();
    }



}
